package com.ftg.shopping.sp_orderinfo.controller;

import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.orderdetails.entity.Orderdetails;
import com.ftg.shopping.sp_orderinfo.entity.SpOrderinfo;
import com.ftg.shopping.sp_orderinfo.service.SpOrderinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "订单管理")
@RestController
@RequestMapping("/api/sp_ordermanagement")
public class SpOrderinfoController {

    @Autowired
    SpOrderinfoService spOrderinfoService;


    @ApiOperation("layui分页查询带模糊")
    @GetMapping("/page2")
    public LayuiPage<SpOrderinfo> page2(@RequestParam int page, @RequestParam int limit, @RequestParam(required = false) String dname){
        return spOrderinfoService.layuipage(page,limit,dname);
    }

    @ApiOperation("修改订单信息")
    @PostMapping("/update")
    public int update( SpOrderinfo d){
        return spOrderinfoService.update(d);
    }


    @ApiOperation("添加一个订单")
    @PostMapping("/insert")
    public  int insertorder(SpOrderinfo g, Orderdetails b){
        return spOrderinfoService.insert(g,b);
    }

    //删除订单管理联动删除订单明细
    @ApiOperation("联动删除")
    @GetMapping("/del1")
    public int del1(int orderid){
        return spOrderinfoService.del1(orderid);
    }




}
